<%@page import="systems.AdsSystem"%>
<%@page import="entities.MetaSeo"%>
<%@page import="helpers.StringHelper"%>
<%@page import="java.util.TreeMap"%>
<%@page import="java.util.Map"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="entities.IpAddress"%>
<%
String error = (String) request.getAttribute("error");
IpAddress ipAddress = (IpAddress) request.getAttribute("ipAddress");
MetaSeo metaseo = (MetaSeo) request.getAttribute("metaseo");

//Set content for Seo
Map<String, String> replates = new TreeMap<String, String>();
replates.put("__SERVER_NAME__", UrlHelper.getDomainServer(request));
replates.put("__SERVER_URL__", UrlHelper.getServerUrl(request));

String title = StringHelper.replateContent(metaseo.getTitle(), replates);
String description = StringHelper.replateContent(metaseo.getDescription(), replates);
String keywords = StringHelper.replateContent(metaseo.getKeywords(), replates);
String url = StringHelper.replateContent(metaseo.getOgurl(), replates);

if (ipAddress != null) {
	replates.put("__IP_ADDRESS__", ipAddress.getIp());
	replates.put("__CITY_NAME__", ipAddress.getCity());
	replates.put("__COUNTRY_NAME__", ipAddress.getCountryName());
	replates.put("__COUNTRY_CODE__", ipAddress.getCountryCode());
	replates.put("__LONGITUDE_CODE__", ipAddress.getLongitude());
	replates.put("__LATITUDE_CODE__", ipAddress.getLatitude());
	
	title = StringHelper.replateContent(metaseo.getTitleInfo(), replates);
	description = StringHelper.replateContent(metaseo.getDescriptionInfo(), replates);
	keywords = StringHelper.replateContent(metaseo.getKeywordsInfo(), replates);
	url = StringHelper.replateContent(metaseo.getOgurlInfo(), replates);
}
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/templates/default/layouts/header.jsp">
	<jsp:param name="title" value="<%=title %>" />
    <jsp:param name="description" value="<%=description %>" />
    <jsp:param name="keywords" value="<%=keywords %>" />
    <jsp:param name="ogtitle" value="<%=title %>" />
    <jsp:param name="ogurl" value="<%=url %>" />
    <jsp:param name="ogdescription" value="<%=description%>" />
</jsp:include>

		<div class="row-fluid clearfix">
			<!-- Main Content -->
			<div class="span9 main-content domain-info">
				<section>
					<div class="block">
						<div class="block-content no-bg">
							<h3>Check Ip</h3>
							<div class="adv">
								<%=AdsSystem.getAds468x15() %>
								<br />
							</div>
							<section id="search-bar">
								<div class="item-stream unstyled search-input-stream">
									<div class="stream-item stream-header search-input-item">
										<form action="/ip" class="form-inline search-form">
											<input type="text" role="textbox" class="xlarge ui-autocomplete-input" id="artist_search" name="q" placeholder="ex: 172.168.192.5" value="">
					          				<button class="btn btn-large btn-inverse" id="artist_submit" type="submit"><i class="icon-search icon-white"></i></button>
										</form>
									</div>
								</div>
							</section>
							
							<% if (ipAddress != null) { %>
							<section class="ip-result">
								<h4>Ip <%=ipAddress.getIp() %> Info</h4>
								
								<div class="content-block">
									<div class="row-fluid">
										<div class="span6 ip-result">
											<ul class="item-list">
												<li class="row-fluid">
													<div class="span4 title">Country Code</div>
													<div class="span8"><%=ipAddress.getCountryCode() %></div>
												</li>
												<li class="row-fluid">
													<div class="span4 title">Country Code3</div>
													<div class="span8"><%=ipAddress.getCountryCode3() %></div>
												</li>
												<li class="row-fluid">
													<div class="span4 title">Country Name</div>
													<div class="span8"><%=ipAddress.getCountryName() %></div>
												</li>
												<li class="row-fluid">
													<div class="span4 title">City</div>
													<div class="span8"><%=ipAddress.getCity() %></div>
												</li>
												<li class="row-fluid">
													<div class="span4 title">Continent Code</div>
													<div class="span8"><%=ipAddress.getContinentCode() %></div>
												</li>
												<li class="row-fluid">
													<div class="span4 title">Latitude</div>
													<div class="span8"><%=ipAddress.getLatitude() %></div>
												</li>
												<li class="row-fluid">
													<div class="span4 title">Longitude</div>
													<div class="span8"><%=ipAddress.getLongitude() %></div>
												</li>
											</ul>
										</div>
										<div class="span6">
											<img src="http://maps.google.com/maps/api/staticmap?sensor=false&size=300x300&markers=size:mid|color:blue|label:1|<%=ipAddress.getLatitude() %>,<%=ipAddress.getLongitude() %>&markers=color:black|label:0|<%=ipAddress.getLatitude() %>,<%=ipAddress.getLongitude() %>">
										</div>
									</div>
									
									<div class="row-fluid f-info">
										<div class="span12">
											<h4>Whois IP <%=ipAddress.getIp() %> Info</h4>
											<div class="adv top-right">
												<%=AdsSystem.getAds468x15() %>
											</div>
											<ul>
												<li>
													<div class="adv pull-right">
														<%=AdsSystem.getAds200x200() %>
													</div>
													<%=ipAddress.getWhoisIp() %>
												</li>
											</ul>
										</div>
									</div>
								</div>
							</section>
							<% } %>
						</div>
					</div>
				</section>
				
			</div>
			<!-- Main Content -->
			
			<!-- slidebar BEGIN -->
			<jsp:include page="/templates/default/elements/right.jsp" />
			<!-- slidebar END -->
		</div>

<jsp:include page="/templates/default/layouts/footer.jsp" />